package org.summerframework.component.security.enumeration;

/**
 * Login type enum
 *
 * @author 石超
 * @version v1.0.0
 */
public enum LoginTypeEnum {
    ERROR_FLOW(-1, "不认识的登录方式", "public/error"),
    NORMAL_FLOW(0, "普通登录", "Normal"),
    DYNAMIC_PSWD_FLOW(1, "动态密码登录", "DynamicPassword"),
    PAGE_LOGIN_FLOW(3, "普通登录", "pagelogin"),
    QRCODE_FLOW(4, "二维码登录", "Qrcode"),
    QQ_FLOW(5, "qq 授权登录", "qq"),
    WECHAT_FLOW(6, "微信第三方平台授权登录", "wechat"),
    WEChAT_MP_FLOW(7, "微信公众号授权登录", "wechatmp"),
    WEIBO_FLOW(8, "weibo 授权登录", "weibo"),
    WECHAT_MINI_APPS(9, "微信小程序", "wechatMiniApps"),
    LOGOUT(10, "退出", "logout"),
    ALIPAY_FLOW(11, "支付宝用户授权", "alipay"),
    ALIPAY_THIRD_PARTY_FLOW(12, "支付宝第三方授权", "alipay_third_party"),
    WECHAT_MOBILE_FLOW(13, "微信手机授权登录", "wechat_mobile"),
    QQ_MOBILE_FLOW(14, "QQ手机授权登录", "qq_mobile"),
    ALIPAY_ACCOUNT_FLOW(15, "支付宝账户绑定", "alipay_account"),
    WECHAT_ACCOUNT_FLOW(16, "微信账户绑定", "wechat_account"),
    POLICE_IN_ACCOUNT_FLOW(17, "警综平台", "police_in"),
    RAPID_ENROLLMENT(18, "token快速登录", "rapid enrollment");

    private int type;            //类型
    private String typeStr;        //类型描述
    private String typeCode;    //类型符号

    LoginTypeEnum(int type, String typeStr, String typeCode) {
        this.type = type;
        this.typeStr = typeStr;
        this.typeCode = typeCode;
    }

    public static LoginTypeEnum getFlowByType(int type) {
        for (LoginTypeEnum lt : values()) {
            if (lt.type == type) {
                return lt;
            }
        }
        return ERROR_FLOW;
    }

    public static LoginTypeEnum getFlowTypeByCode(String typeCode) {
        for (LoginTypeEnum lt : values()) {
            if (lt.typeCode.equalsIgnoreCase(typeCode)) {
                return lt;
            }
        }
        return ERROR_FLOW;
    }

    public boolean isType(Integer code) {
        return this.type == code;
    }

    public int getType() {
        return type;
    }

    public String getTypeStr() {
        return typeStr;
    }

    public String getTypeCode() {
        return typeCode;
    }

}
